﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class BaseUI : MonoBehaviour {

    
    protected void Awake()
    {
        Init_Node(this.transform);
    }
    public virtual void LoadInit(string level=null)
    {
        
    }

    public void Init_Node(Transform tf)
    {
        Button btn = tf.GetComponent<Button>();
        BindCompotent(tf.gameObject.name,tf.gameObject);
        if (btn != null)
        {
            btn.onClick.AddListener(() => { OnButtonClick(btn.name); });
        }
        for (int i = 0; i < tf.childCount; i++)
        {
            Init_Node(tf.GetChild(i));
        }
    }
    public virtual void BindCompotent(string imgName,GameObject go) { }
    public virtual void OnButtonClick(string btnName) { }
    public virtual void ExitUI()
    {
        Destroy(this.gameObject);
    }
    
}
